package com.reus.client;

import com.reus.api.model.Order;
import com.reus.api.model.User;
import com.reus.api.service.OrderService;
import com.reus.api.service.UserService;
import com.reus.core.netty.proxy.RpcByteBuddy;
import com.reus.core.netty.proxy.RpcClient;
import com.reus.core.netty.proxy.RpcClientJdk;
import lombok.extern.slf4j.Slf4j;

/**
 * description:
 * copyright: Copyright (c) 2018-2021
 * company: iSysCore Tech. Co., Ltd.
 *
 * @author liuxq@isyscore.com
 * @version 1.0
 * @date 2021-09-28 13:39:10
 */
@Slf4j
public class ClientApplication {

    public static void main(String[] args) {

        RpcClient jdk = new RpcClientJdk();
        UserService userService = jdk.create(UserService.class, "http://localhost:8080/");
        User user = userService.findById(1);
        if (user == null) {
            log.info("Clint service invoke Error");
            return;
        }
        System.out.println("find user id=1 from server: " + user.getName());

        RpcClient buddy = new RpcByteBuddy();
        OrderService orderService = buddy.create(OrderService.class, "http://localhost:8080/");
        Order order = orderService.findById(1992129);
        if (order == null) {
            log.info("Clint service invoke Error");
            return;
        }
        System.out.println(String.format("find order name=%s, user=%d", order.getName(), order.getUserId()));
    }
}
